package com.ponxu.log;

public abstract class Log {
	public static final int TRACE = 1;
	public static final int DEBUG = 2;
	public static final int INFO = 3;
	public static final int WARN = 4;
	public static final int ERROR = 5;
	public static final int FATAL = 6;

	protected static String format(Object message, Object... args) {
		if (message == null) {
			return null;
		}
		return String.format(message.toString(), args);
	}

	private String name;

	public Log(String name) {
		this.name = name;
	}

	public abstract void log(int level, Object message, Object... args);

	public abstract void log(int level, Object message, Throwable t,
			Object... args);

	public String getName() {
		return name;
	}

	public void trace(Object message, Object... args) {
		log(TRACE, message, args);
	}

	public void trace(Object message, Throwable t, Object... args) {
		log(TRACE, message, t, args);
	}

	public void debug(Object message, Object... args) {
		log(DEBUG, message, args);
	}

	public void debug(Object message, Throwable t, Object... args) {
		log(DEBUG, message, t, args);
	}

	public void info(Object message, Object... args) {
		log(INFO, message, args);
	}

	public void info(Object message, Throwable t, Object... args) {
		log(INFO, message, t, args);
	}

	public void warn(Object message, Object... args) {
		log(WARN, message, args);
	}

	public void warn(Object message, Throwable t, Object... args) {
		log(WARN, message, t, args);
	}

	public void error(Object message, Object... args) {
		log(ERROR, message, args);
	}

	public void error(Object message, Throwable t, Object... args) {
		log(ERROR, message, t, args);
	}

	public void fatal(Object message, Object... args) {
		log(FATAL, message, args);
	}

	public void fatal(Object message, Throwable t, Object... args) {
		log(FATAL, message, t, args);
	}
}
